package numbers.primenumbers;

import java.util.ArrayList;
import java.util.List;

public class getPrimesNumbers {

	public static void main(String[] args) {

		System.out.println(getNumberOfPrimes(100));
	}

	private static int getNumberOfPrimes(int interval) {

		List<Integer> previousSimpleNumbers = new ArrayList<Integer>();

		for (int index = 0; index < interval; index++) {
			if (isPrimeNumber(index, previousSimpleNumbers)) {
				previousSimpleNumbers.add(index);
			}
		}

		return previousSimpleNumbers.size();
	}

	private static boolean isPrimeNumber(Integer number,
			List<Integer> previousSimpleNumbers) {
		
		if (number < 2) {
			return false;
		}

		
		for (Integer currentNumber : previousSimpleNumbers) {

			Integer div = number % currentNumber;
			if (div == 0) {
				return false;
			}

		}

		return true;
	}

}
